angular.module('codeService', [])
    .service('codeApi', function () {
        this.getCode = function () {
            var codeStr = 'abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ0123456789';
            var len = codeStr.length;
            var str = '';
            var max = Math.ceil(Math.random() * (8 - 4) + 4);
            for (var i = 1; i < max; i++) {
                var index = Math.floor(Math.random() * len);
                str += codeStr.substr(index, 1);
            }
            return str;
        };
        return this;
    });